Skip to content

Conversation

@lucasgoral
Copy link
Contributor

@lucasgoral lucasgoral commented Nov 20, 2025

What this PR does / why we need it:

Added logic to show error page with info when user is not authorized to access MCP

@lucasgoral lucasgoral changed the title Mcp where user is not member showing generic bug Added 'Access Denied' screen for unauthorized MCP users Nov 21, 2025
@lucasgoral lucasgoral marked this pull request as ready for review November 21, 2025 07:47
Copilot AI review requested due to automatic review settings November 21, 2025 07:47
Copilot finished reviewing on behalf of lucasgoral November 21, 2025 07:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an authorization layer to the Managed Control Plane (MCP) page to display an "Access Denied" screen when users lack permission to view MCP resources. The implementation checks user authorization by attempting to access CRD resources and handles 401/403 errors appropriately.

Key Changes

  • Added ManagedControlPlaneAuthorization wrapper component that checks user permissions via CRD access
  • Created reusable Center component for centering content vertically and horizontally
  • Enhanced Infobox component with size-specific icon styling and noMargin prop

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/spaces/mcp/authorization/ManagedControlPlaneAuthorization.tsx New authorization wrapper component that checks CRD access and shows access denied screen for unauthorized users
src/spaces/mcp/pages/McpPage.tsx Wraps MCP page content with authorization check and updates loading indicator to use Center component
src/lib/api/types/crossplane/CRDList.ts Adds CRDRequestAuthCheck resource with jq filter for lightweight authorization checks
src/components/Ui/Center/Center.tsx New utility component for centering content with flexbox
src/components/Ui/Center/Center.module.css Styles for the Center component
src/components/Ui/Infobox/Infobox.tsx Adds noMargin prop and size-specific icon styling
src/components/Ui/Infobox/Infobox.module.css Adds icon-sm, no-margin styles, and updates size-sm styling
src/components/Ui/NotFoundBanner/NotFoundBanner.tsx Wraps content with Center component for consistent positioning
src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx Fixes logic to show either warning or connect button (not both)
src/lib/shared/McpContext.tsx Removes trailing whitespace
public/locales/en.json Adds translation keys for access denied messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import { useApiResource } from '../../../lib/api/useApiResource.ts';

export interface ManagedControlPlaneAuthorizationProps {
mcp: ControlPlaneType;
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mcp prop is defined in the interface but never used in the component. If it's not needed for the current implementation, it should be removed from the interface. If it will be needed in the future, consider adding a comment explaining its intended use.

Suggested change
mcp: ControlPlaneType;

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +30
const onBack = () => {
if (workspaceName) {
navigate(
generatePath(Routes.Project, {
projectName: projectName ?? '',
}),
);
}
};
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onBack function only navigates when workspaceName is truthy, but the button is always rendered. This means the button will do nothing when workspaceName is falsy. Consider either:

  1. Hiding the button when navigation is not possible
  2. Always navigating (remove the conditional), or
  3. Providing a fallback navigation target

Copilot uses AI. Check for mistakes.
<MCPHealthPopoverButton
mcpStatus={mcp?.status}
projectName={projectName}
workspaceName={workspaceName ?? ''}
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This use of variable 'workspaceName' always evaluates to true.

Suggested change
workspaceName={workspaceName ?? ''}
workspaceName={workspaceName}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants